package conchmusic.conchmusicclient.mainUi;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;

import conchmusic.conchmusicclient.R;
import conchmusic.conchmusicclient.dao.ClientControl;
import conchmusic.conchmusicclient.dao.MyDBHelp;

public class StartActivity extends AppCompatActivity {
    private final int DisplayTime=1000;
    private MyDBHelp myDBHelp;
    private ClientControl cc;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);
        myDBHelp = new MyDBHelp(this, "demon", null, 1);
        cc = new ClientControl(myDBHelp);
//判断是否登录，如果登录了，直接跳转主页面
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                judge();
                finish();
            }
        },DisplayTime);
    }
    public void judge(){
        if(cc.Login()!=null){//判断登录状态
            Intent intent = new Intent();
            intent.setClass(this, MainActivity.class);
            startActivityForResult(intent, 1);
        }else {
            Intent intent = new Intent();
            intent.setClass(this, LoginActivity.class);
            startActivity(intent);
        }
    }
}
